From ba95c3c2feb45fdda0c33737038bf264ced7e280 Mon Sep 17 00:00:00 2001 From: robertl Date: Tue, 9 Nov 2004 16:54:53 +0000 Subject: [PATCH] Fix case when source string consists of nothing but spaces. (Thanx, holux...) --- gpsbabel/mkshort.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gpsbabel/mkshort.c b/gpsbabel/mkshort.c index 1c447244d..19ec3a51e 100644 --- a/gpsbabel/mkshort.c +++ b/gpsbabel/mkshort.c @@ -290,8 +290,12 @@ mkshort(void *h, const char *istring) ostring = nstring; /* Eliminate leading whitespace in all cases */ - while (isspace(ostring[0])) { - memmove(&ostring[0], &ostring[1], strlen(ostring)-1); + while (ostring[0] && isspace(ostring[0])) { + /* If orig string has N bytes, we want to copy N-1 bytes + * of the string itself plus the string terminator (which + * matters if the string consists of nothing but spaces) + */ + memmove(&ostring[0], &ostring[1], strlen(ostring)); } if (!hdl->whitespaceok) { -- 2.30.2